package cz.muni.fi.pb138.mathml_canonicalizator;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 *
 * @author ndru
 */
public class MsubsupTransformer implements Transformer {

    private int index = 0;
    private Node msup;
    private Node msub;

    public MsubsupTransformer(Map<String, String> attrs, 
            Map<String, List<String>> properties) {
        
        List<String> attr_keep = properties.get("attr_keep") != null ?
                properties.get("attr_keep") : new ArrayList<String>();
        
        Util.removeAtrributes(attrs, attr_keep);
        
        msup = new NodeImpl("msup", attrs);
        msub = new NodeImpl("msub", null);
        msup.addChild(msub);
    }

    @Override
    public void addChild(Node n) {
        switch(index++){
            case 0:
            case 1:
                msub.addChild(n);
                break;
            case 2:
                msup.addChild(n);
                break;
        }
    }

    @Override
    public void setTextContent(String s) {
    }

    @Override
    public Node transform() {
        return msup;
    }
}
